package br.com.base.model.impl;

import java.util.Date;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import br.com.base.model.Entidade;
import br.com.base.model.UsuarioBase;

/**
 * @author Milton Domingues
 */
@MappedSuperclass
public abstract class EntidadeImpl implements Entidade<Long>{

	private static final long serialVersionUID = -3007501547856087416L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Temporal(TemporalType.TIMESTAMP)
	private Date dataInclusao;

	@Temporal(TemporalType.TIMESTAMP)
	private Date dataAlteracao;

	public EntidadeImpl() {

	}

	@Override
	public boolean equals(Object obj) {
		boolean equals = false;
		try{
			if ((getId().equals(((EntidadeImpl) obj).getId()))) {
				equals = true;
			} else if (obj == this) {
				equals = true;
			}
		} catch (ClassCastException e) {
			equals = false;
		}
		return equals;
	}


	public Date getDataAlteracao() {
		return this.dataAlteracao;
	}

	public Date getDataInclusao() {
		return this.dataInclusao;
	}

	@Override
	public Long getId() {
		return this.id;
	}

	public void setDataAlteracao(Date dataAlteracao) {
		this.dataAlteracao = dataAlteracao;
	}

	public void setDataInclusao(Date dataInclusao) {
		this.dataInclusao = dataInclusao;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setUsuarioAlteracao(UsuarioBase usuarioAlteracao){

	}

	public void setUsuarioInclusao(UsuarioBase usuarioInclusao){

	}

}
